#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int num[10000];
void swap(int* a, int* b)
{
	int tmp = *a;
	*a = *b;
	*b = tmp;
}
int quicksort(int l, int r,int k)
{
	if (l == r)
	{
		return num[l];
	}
	int mid = (l + r) / 2, i = l, j = r;
	while (i < j)
	{
		while (num[i++] < num[mid]);
		while (num[j--] > num[mid]);
		if (i < j)
		{
			swap(num[i], num[j]);
		}
	}
	if (k <= j)
	{
		quicksort(l, j, k);
	}
	else
	{
		quicksort(j+1, r, k);
	}
}
int main()
{
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> num[i];
	}
	int l = 0, r = n - 1;
	cout<<quicksort(l,r,k)<<'\n';
	return 0;
}